﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace eVoteClient
{
    public partial class ViewResults : Form
    {
        string[] answers;
        string[] values;

        public ViewResults(string[] answers, string[] values)
        {
            InitializeComponent();

            this.answers = answers;
            this.values = values;

            DataTable dt = new DataTable();
            DataColumn dc;

            dc = new DataColumn();
            dc.ColumnName = "Answer";
            dt.Columns.Add(dc);
            dc = new DataColumn();
            dc.ColumnName = "Value";
            dt.Columns.Add(dc);

            DataRow dr;

            for (int i = 0; i < answers.Length; i++)
            {
                dr = dt.NewRow();
                dr["Answer"] = answers[i];
                dr["Value"] = Convert.ToInt32(values[i]);
                dt.Rows.Add(dr);
            }

            chart1.DataSource = dt;
            chart1.Series["Series1"].XValueMember = "Answer";
            chart1.Series["Series1"].YValueMembers = "Value";
            chart1.DataBind();
            //chart1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.None;
            //chart1.BackColor = Color.Transparent;
            chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
            chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
            chart1.ChartAreas["ChartArea1"].AxisX.MinorGrid.Enabled = false;
            chart1.ChartAreas["ChartArea1"].AxisY.MinorGrid.Enabled = false;
            chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
            chart1.ChartAreas["ChartArea1"].AxisY.IsMarginVisible = false;
            chart1.ChartAreas["ChartArea1"].AxisX.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
            chart1.ChartAreas["ChartArea1"].AxisX.MajorTickMark.Enabled = false;
            chart1.ChartAreas["ChartArea1"].AxisY.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.False;
            chart1.Series["Series1"].IsValueShownAsLabel = true;
            //chart1.Series["Series1"].LabelStyle.MovingDirection = System.Windows.Forms.DataVisualization.Charting.LabelAlignmentStyles.Left;
            chart1.BackColor = Color.Transparent;
            chart1.ChartAreas["ChartArea1"].BackColor = Color.Transparent;
            chart1.Legends["Legend1"].Enabled = false;
            chart1.Visible = true;
        }

        private void chart1_Click(object sender, EventArgs e)
        {

        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            new Home().Show();
            this.Hide();
        }

        private void ViewResults_Load(object sender, EventArgs e)
        {
            this.Location = new Point(350, 200);
            this.Size = new Size(572, 324);
        }
    }
}
